In video coding, a residual transform coefficient, for example, a discrete cosine transform (DCT for short) coefficient, of a picture block after prediction needs to be quantized before being coded, where quantization weights at a position of each frequency coefficient of each transform block are a quantization MATRIX (QM for short). A size of a QM equals a size of a DCT transform block. For example, a DCT transform block having a size of 32×32 needs to correspond to a 32×32 QM. Meanwhile, different QMs are also required for different signal components and different (intra-frame/inter-frame) prediction modes of a picture block. An element of a QM is an integer ranging from 0 to 255. Generally, for a low-frequency coefficient, a quantization weight in the QM is small, and for a high-frequency coefficient, a quantization weight in the QM is large. The QM may be used to improve picture subjective quality of a coded video.
At present, in picture coding standards such as JPEG (Joint Photographic Experts Group), MPEG-1 (MPEG, Moving Picture Experts Group), MPEG-2, and MPEG-4, a quantization MATRIX is used to implement subjective quality improvement for a coded picture. In the JPEG picture coding standard, a QM is placed in a picture header; in picture coding standards as MPEG-1, MPEG-2, and MPEG-4, a QM is placed in a sequence header. Therefore, for a sequential picture, each sequence has one QM according to the MPEG picture coding standards. That is, a same sequence uses a same fixed QM to implement quantization processing on a picture.
Picture contents in a picture sequence are not exactly the same. That is, each picture in a same picture sequence depicts different details. Therefore, if a same QM is used to implement quantization processing on all pictures of the entire sequence, evidently, optimal picture subjective quality after quantization and coding cannot be achieved. Therefore, in H.264/Advanced Video Coding (AVC for short), a user-defined QM is provided both in a sequence header and a picture header, so that a QM is changeable for pictures, thereby better satisfying a characteristic of greatly changing contents between video sequential pictures.
The following describes several representative QM implementation methods that are common in existing coding standards:
(1) Quantization MATRIX in JPEG
In the JPEG standard, only one 8×8 DCT (discrete cosine transform) transform size is available. Therefore, a size of a quantization MATRIX is also 8×8, and a total of 64 quantization coefficients are available. Different quantization matrices are used for luma components and chroma components of a picture. All coefficient values of the quantization matrices of JPEG are placed in a picture header, and each picture has only one luma quantization MATRIX and chroma quantization MATRIX. When a quantization MATRIX predefined by default in the standard is used at coding and decoding ends, the quantization MATRIX does not need to be transmitted in a bit stream.
(2) MPEG-2
In the MPEG-2 standard, only one 8×8 DCT transform size is available. Therefore, a size of a quantization MATRIX is also 8×8, and a total of 64 quantization coefficients are available. An intra-frame quantization MATRIX and an inter-frame quantization MATRIX are respectively used for a coded picture. MPEG-2 only allows all pictures in each sequence to have only one intra-frame quantization MATRIX and one inter-frame quantization MATRIX, and the quantization matrices are placed in a sequence header. MPEG-2 also allows a user-defined quantization MATRIX, where the user-defined quantization MATRIX is placed in a sequence extension header. Because the quantization matrices of each sequence cannot be changed, the quantization matrices directly coded into a bit stream do not cause a heavy load.
(3) H.264/AVC Standard
In the H.264/AVC standard, two DCT transform sizes, namely, 8×8 and 4×4, are available. Therefore, two groups of corresponding quantization matrices, 8×8 and 4×4, are also available. The 8×8 quantization MATRIX has a total of 64 coefficients to perform quantization scaling on different frequency components; and the 4×4 quantization MATRIX has a total of 16 coefficients to perform quantization scaling on different frequency components. A 4×4 block and an 8×8 block both have a corresponding quantization MATRIX, the quantization MATRIX is used in picture header syntax. At present, a QM is coded and transmitted in a bit stream by using the following method in H.264/AVC: scanning a QM into a one-dimensional array first; performing modulation by using differential pulse code modulation (DPCM for short); and then coding modulated data by using variable-length code coding and outputting a bit stream. In this method, lossless compression is directly performed on the QM; however, compression efficiency thereof is low, and a high bit rate is still occupied by coded bits of the QM, especially for a bit stream sequence having a small picture size. Therefore, in order to limit a load of the quantization MATRIX in a bit stream of each frame of a coded picture, use of the quantization MATRIX in a picture header is limited only to the H.264/AVC High Profile standard, and the quantization MATRIX is used for high-definition picture coding.
In High Efficiency Video Coding (HEVC for short), transform sizes of a picture block are increased to a plurality of transform sizes, such as 4×4, 8×8, 16×16, and 32×32. Moreover, because a larger transform block is used, a corresponding QM is also larger. If a QM is coded without being compressed or by using the H.264/AVC method, the QM occupies a high bit rate, where coded bits of the QM itself may occupy half or even several times of the bit rate.